package org.example.service.impl;

import org.example.dao.OrderGoodsMapper;
import org.example.dao.OrderMapper;
import org.example.dto.Goods;
import org.example.dto.Order;
import org.example.rvo.ResultVO;
import org.example.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;

    @Resource
    private OrderGoodsMapper orderGoodsMapper;

    @Override
    public ResultVO createOrder(Order order, Goods goods) throws Exception {
       orderMapper.insertOrder(order.getId(),order.getUId());
       orderGoodsMapper.insertOrderGoods(order.getId(), goods.getId());
       return ResultVO.success("200","订单创建成功");
    }

    @Override
    public ResultVO queryOrder(Integer id) throws Exception {
        return ResultVO.success("200","success",orderMapper.selectOrder(id));
    }
}
